﻿using AnesSystem.Models;
using MongoDB.Bson;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AnesSystem.Services
{
    public class AccountService:BaseService<AccountService,AccountModel>
    {
        //查询所有账号，去掉重复
        public List<AccountModel> seachAccountAll(string loginName, string pwd)
        {
            return null;
        }

        //用于登录查询
        public List<AccountModel> seachAccountByLoginName(string loginName)
        {
            var filter = Builders<BsonDocument>.Filter;
            var query = Builders<BsonDocument>.Filter.And(Builders<BsonDocument>.Filter.Eq("LoginName", loginName));
            return FindAll(query).ToList();
        }

        //用于登录查询
        public List<AccountModel> seachAccountByNameAndPwd(string loginName,string pwd)
        {
            var filter = Builders<BsonDocument>.Filter;
            var query = Builders<BsonDocument>.Filter.And(Builders<BsonDocument>.Filter.Eq("LoginName", loginName),
                Builders<BsonDocument>.Filter.Eq("Pwd", pwd));
            return FindAll(query).ToList();
        }

        //用于人名查询
        public List<AccountModel> findAccountListByName(string accountName)
        {
            var filter = Builders<BsonDocument>.Filter;
            var query = Builders<BsonDocument>.Filter.And(Builders<BsonDocument>.Filter.Eq("trueName", accountName));
            return FindAll(query).ToList();
        }
        
    }
}
